import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

import headModule from './modules/headModule'
import footerModule from './modules/footerModule'
import cityModule from './modules/cityModule'
import cinemaModule from './modules/cinemaModule'
import goodsModule from './modules/goodsModule'
import addressModule from './modules/addressModule'
import payModule from './modules/payModule'

Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [createPersistedState({
    // storage: window.sessionStorage, // 默认是localStorage
    reducer (val) {
      return {
        // 储存项
        cityModule: val.cityModule
      }
      // 默认全部储存
    }
  }), createPersistedState({
    storage: window.sessionStorage, // 默认是localStorage
    reducer (val) {
      return {
        // 自定义储存项
        cinemaModule: val.cinemaModule,
        goodsModule: val.goodsModule,
        addressModule: val.addressModule
      }
      // 默认全部储存
    }
  })],
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    headModule,
    footerModule,
    cityModule,
    cinemaModule,
    goodsModule,
    addressModule,
    payModule
  }
})
